package test2;

import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.TextMessage;

import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.command.ActiveMQQueue;

public class TestPTPProducer {
	public static void main(String[] args) throws Exception {
		ConnectionFactory factory = new ActiveMQConnectionFactory("tcp://10.222.29.178:61616");
		Destination queue = new ActiveMQQueue("jason");
		Connection con = factory.createConnection();
		con.start();
		
		Session session = con.createSession(false, Session.CLIENT_ACKNOWLEDGE);
		MessageProducer producer = session.createProducer(queue);
		
		TextMessage msg1 = session.createTextMessage("Hello1!");
		TextMessage msg2 = session.createTextMessage("Hello2!");
		producer.send(msg1);
		producer.send(msg2);
		
		producer.close();
		session.close();
		con.close();	//connection没关闭，程序不会结束
	}
}
